package com.easylinkin.linkappapi.ruleengine.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.easylinkin.linkappapi.alarm.entity.AlarmTemplate;
import com.easylinkin.linkappapi.linkage.entity.LinkageConfigRefDownDevice;
import com.easylinkin.linkappapi.linkage.entity.LinkageConfigRelateServiceParm;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Set;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 执行器
 * </p>
 *
 * @author TongJie
 * @since 2020-08-24
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("rule_execution")
@ApiModel("规则执行器实体类")
public class RuleExecution extends Model<RuleExecution> {

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId("id")
    @ApiModelProperty(value = "主键", example = "")
    private String id;

    /**
     * 类型：1-下行服务，2-告警工单
     */
    @TableField("type")
    @ApiModelProperty(value = "类型", example = "1")
    private Integer type;

    @TableField("delay_time")
    @ApiModelProperty(value = "延迟时间", example = "1")
    private Double delayTime;

    /**
     * 规则引擎id
     */
    @TableField("rule_engine_id")
    @ApiModelProperty(value = "规则引擎id", example = "")
    private String ruleEngineId;

    /**
     * 规则引擎
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "规则引擎实体类", example = "")
    private RuleEngine ruleEngine;

    /**
     * 设备型号id  type为1-下行服务 才有该参数
     */
    @TableField("device_unit_id")
    @ApiModelProperty(value = "设备型号id", example = "")
    private String deviceUnitId;

    /**
     * 新型号id
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "新型号id", example = "")
    private String newDeviceUnitId;

    /**
     * 租户id
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "租户id", example = "")
    private String tenantId;


    /**
     * 排序标记
     */
    @TableField("sort_flag")
    @ApiModelProperty(value = "排序标记", example = "")
    private String sortFlag;

    /**
     * 告警通知模板id(只有type为2-告警工单时，才有值)
     */
    @TableField("alarm_template_id")
    @ApiModelProperty(value = "告警通知模板id", example = "")
    private String alarmTemplateId;

    /**
     * 告警模板
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "告警模板", example = "")
    private AlarmTemplate alarmTemplate;

    /**
     * 创建时间
     */
    @TableField("create_time")
    @ApiModelProperty(value = "创建时间", example = "")
    private Date createTime;

    /**
     * 修改时间
     */
    @TableField("modify_time")
    @ApiModelProperty(value = "修改时间", example = "")
    private Date modifyTime;

    /**
     * 是否 对应的规则条件 包含自触发
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "是否 对应的规则条件 包含自触发", example = "")
    private Boolean selfTrigger;

    /**
     * 服务参数
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "服务参数", example = "")
    private List<LinkageConfigRelateServiceParm> linkageConfigRelateServiceParms;

    /**
     * 关联下行设备
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "关联下行设备", example = "")
    private List<LinkageConfigRefDownDevice> linkageConfigRefDownDeviceList;

    /**
     * 关联下行设备
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "关联下行设备", example = "")
    private List<RuleExecutionRefAlarmPersonContact> ruleExecutionRefAlarmPersonContactList;

    /***
     * 规则引擎ids
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "规则引擎ids", example = "")
    private Set<String> ruleEngineIds;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}
